40823136

  • Home
    • Site Map
    • reveal
    • blog
  • First
  • About
  • stage1
    • w1
      • 建立網頁
      • 編輯leo
    • w2
      • 討論與影片
      • 圖檔
    • w3
      • 投石機(1)
      • 投石機(2)
      • 投石機(3)
      • 簡報-1
  • stage2
    • w5
      • stage2組員
    • w6
      • heroku
      • 選訂題目
    • w7
      • 自動化生產線(1)-用程式控制機械手臂與調整
    • w8
      • 自動化生產線(2)
    • w9
      • 自動化生產線(3)最終版
    • 簡報-2
  • stage3
    • w10
      • task1
      • task2-1
      • task2-2-python Remote API程式控制機械手臂
      • task2-3
    • w13
      • 第一組線上直播
      • RoboDK
    • w15
      • Video and subtitle translation-1
      • Video and subtitle translation-2
    • w16
      • Onshape 零組件繪製
      • 建立 CoppeliaSim 4.1.0 MTB robot 場景
      • 手臂末端加入 components-gripper-suction pad 吸盤跟鍵盤控制
      • 逆向運動學函式-鍵盤控制與程式迴圈方式
      • Python remote API 逆向運動學函式
  • stage3 專案
    • 自動化(1)
    • 自動化(2)
    • 自動化(3)
    • 心得
  • W18
    • 期末影片
task2-1 << Previous Next >> task2-3

task2-2-python Remote API程式控制機械手臂

import sim as vrep
import sys
import math
# child threaded script: 
#simExtRemoteApiStart(19999)
 
vrep.simxFinish(-1)
 
clientID = vrep.simxStart('127.0.0.1', 19999, True, True, 5000, 5)
 
if clientID!= -1:
    print("Connected to remote server")
else:
    print('Connection not successful')
    sys.exit('Could not connect')
    

 
vrep.simxStartSimulation(clientID, vrep.simx_opmode_oneshot)
 
RC1,handle1 = vrep.simxGetObjectHandle(clientID, 'motor1', vrep.simx_opmode_blocking)
RC2,handle2 = vrep.simxGetObjectHandle(clientID, 'motor2', vrep.simx_opmode_blocking)
RC3,handle3 = vrep.simxGetObjectHandle(clientID, 'motor3', vrep.simx_opmode_blocking)
RC4,handle4 = vrep.simxGetObjectHandle(clientID, 'motor4', vrep.simx_opmode_blocking)
 
vrep.simxSetJointTargetPosition(clientID,handle1,0*math.pi/180,vrep.simx_opmode_oneshot_wait)
vrep.simxSetJointTargetPosition(clientID,handle2,30*math.pi/180,vrep.simx_opmode_oneshot_wait)
vrep.simxSetJointTargetPosition(clientID,handle3,0*math.pi/180,vrep.simx_opmode_oneshot_wait)
vrep.simxSetJointTargetPosition(clientID,handle4,90*math.pi/180,vrep.simx_opmode_oneshot_wait)

目前還出現一個問題,motor2還無法順利作動還在找哪裡錯誤


task2-1 << Previous Next >> task2-3

Copyright © All rights reserved | This template is made with by Colorlib